package main

import (
	"context"
	"fmt"
	"micro/lesson1_basic_GRPC/proto/user"

	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
)

func main() {
	// dial过期 使用NewClient
	client, err := grpc.NewClient("localhost:8080", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		panic(err)
	}
	defer client.Close()

	c := user.NewUserClient(client)
	res, err := c.GetUser(context.Background(), &user.GetUserReq{Id: 2})
	if err != nil {
		panic(err)
	}
	fmt.Println(res)
}
